package cn.com.cym.gamezao.web.grk;

import cn.com.cym.gamezao.annotation.AuthToken;
import cn.com.cym.gamezao.base.BaseController;
import cn.com.cym.gamezao.base.BaseService;
import cn.com.cym.gamezao.dto.SampleSearchDto;
import cn.com.cym.gamezao.entity.grk.Sample;
import cn.com.cym.gamezao.service.grk.SampleService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "grk-患者信息")
@RestController
@AllArgsConstructor
@RequestMapping(value = "grk/sample")
@AuthToken(rule = "grk.sample")
public class SampleController extends BaseController<Sample> {
    final SampleService thisService;
    @Override
    public BaseService<Sample> getService() {
        return thisService;
    }

    @ApiImplicitParam(name = "sample", value = "sample", required = true,dataType = "Sample")
    @ApiOperation(value = "保存")
    @ApiOperationSupport(order = 1, author = "mr.chen")
    @PostMapping("")
    @AuthToken(rule = "save",require = false)
    public ResponseEntity<?> save(@RequestBody Sample sample) {
        Sample save = this.thisService.save(sample);
        return ResponseEntity.ok(save);
    }

    @ApiImplicitParam(name = "searchPage", value = "searchPage", required = true,dataType = "DiagnoseSearchDto")
    @ApiOperation(value = "分页显示page！")
    @ApiOperationSupport(order = 4, author = "mr.chen")
    @PostMapping("/pageSearch")
    @AuthToken(rule = "search")
    public ResponseEntity<?> pageBySearch(@RequestBody SampleSearchDto searchPage){
        Page<Sample> byPageable = thisService.findPageBySearchDto(searchPage);
        return ResponseEntity.ok(byPageable);
    }

}
